import request from '@/utils/request.js'

/** 获取指定频道的文章列表
 *
 * @param {*} channelId 频道ID
 * @param {*} timeStamp 时间戳
 */
export const getArticles = (channelId, timeStamp) => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params: {
      channel_id: channelId,
      timestamp: timeStamp,
      with_top: 1
    }
  })
}

/** 对文章不感兴趣
 *
 * @param {*} articleId 文章ID
 */
export const disLike = (articleId) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

/**
 * 举报文章
 * @param { } articleId 举报文章的id
 * @param {*} typeId 举报类型
 */
export const reportArticle = (articleId, reportType) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/reports',
    data: {
      target: articleId,
      type: reportType
    }
  })
}

/**
 * 获取文章详情
 * @param {*} articleId
 */
export const getDetail = articleId => {
  return request({
    method: 'GET',
    url: '/app/v1_0/articles/' + articleId
  })
}
